package com.btkjgc.service.impl;

import org.springframework.stereotype.Component;

import com.btkjgc.models.AdminUser;
import com.btkjgc.service.intf.LoginService_Intf;
import com.btkjgc.utils.HibernateUtil;

/**
 * Created by _ESE on 2015/2/6.
 */
@Component
public class LoginService_Impl implements LoginService_Intf
{

	@Override
	public AdminUser getAdminByName(String loginname)
	{
		String hql = "from AdminUser where loginname=? and del=0 order by id ";
		String[] parameter = { loginname };
		return (AdminUser) HibernateUtil.executeQueryOneObject(hql, parameter);
	}

	@Override
	public void updateAdmin(AdminUser adminUser)
	{
		HibernateUtil.update(adminUser);
	}

	@Override
	public void updateLastLoginTp(int id, String ip)
	{
		String hql = "update AdminUser set lastip=? where id=" + id;
		String[] parameter = { ip };
		HibernateUtil.executeUpdate(hql, parameter);
	}

}
